from fastapi import Query, Depends, Path

from app.core.BaseResponse import success
from app.model import mysql
from app.service.jwt_service import get_current_user
from app.validator.app import schemas
from app.service import designers_service


async def masters(
        page: int = Query(1),
        keyword: str = Query(None),
        navids: str = Query(None),
        current_user: schemas.User = Depends(get_current_user),
):
    """
    获取大师列表
    :param navids:
    :param keyword:
    :param current_user:
    :param page:
    :return:
    """
    designer = await designers_service.masters(page, keyword, navids, current_user)
    return success(designer)


async def master_case(
        page: int = Query(1),
        navids:  str = Query(None),
        keyword: str = Query(None),
        current_user: schemas.User = Depends(get_current_user),
):
    """
    大师案例
    :param navids:
    :param keyword:
    :param page:
    :param current_user:
    :return:
    """
    case = await designers_service.master_case(page, keyword, navids, current_user)
    return success(case)


async def master_detail(
        master_id: int = Path(...),
        current_user: schemas.User = Depends(get_current_user),
):
    """
    大师详情
    :param master_id:
    :param current_user:
    :return:
    """
    result = await designers_service.master_detail(master_id, current_user)

    return success(result)


